package com.fengcheng.service.Impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fengcheng.mapper.UserMapper;
import com.fengcheng.pojo.User;
import com.fengcheng.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Slf4j
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper,User> implements UserService {

    @Autowired
    private UserMapper userMapper;

/*
 * @author 枫城
 * @createTime 2022/6/30 15:51
 * @desc 插入数据库
 */
    @Override
    public void InsertUser(String name, String password) {
        try {
            userMapper.InsertUser(name,password);
            log.info("插入成功！");
        }catch (Exception e){
            e.printStackTrace();
            log.info("插入失败！");
        }
    }

    @Override
    public User queryByName(String name) {
        return   userMapper.queryByName(name);
    }

    @Override
    public void DeleteUser(String name) {


           try {
               userMapper.DeleteUser(name);
               log.info("删除成功");
           }catch (Exception e){
               e.printStackTrace();
               log.info("删除失败，用户不存在");
           }
       }


}


